package com.ll.studentservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ll.servicebase.exceptionhandler.LLException;
import com.ll.studentservice.entity.*;
import com.ll.studentservice.entity.vo.*;
import com.ll.studentservice.mapper.EduSignMapper;
import com.ll.studentservice.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.junit.Test;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.time.*;
import java.util.*;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ll
 * @since 2020-11-26
 */
@Service
public class EduSignServiceImpl extends ServiceImpl<EduSignMapper, EduSign> implements EduSignService {

    @Autowired
    private EduStudentService eduStudentService;

    @Autowired
    private EduKeService eduKeService;

    @Autowired
    private EduKeInfoService eduKeInfoService;

    @Autowired
    private EduStartWeekService eduStartWeekService;

    @Autowired
    private EduClassService eduClassService;

    @Autowired
    private EduProfessionService eduProfessionService;

    //测试
//    @Test
//    public void test() {
//        LocalDate localDate = LocalDate.now();
//        LocalDate of = LocalDate.of(2020, 3, 8);
//        DayOfWeek dayOfWeek = of.getDayOfWeek();
//        //获得星期数
//        int i = of.get(ChronoField.DAY_OF_WEEK);
//
//        LocalDate of1 = LocalDate.of(2020, 11, 27);
//        LocalDate localDate1 = of1.plusWeeks(1);
//        System.out.println(localDate1);
//    }

    //以班级为入口,查询出所有需要签到的学生(List<Student>)
    @Override
    public List<EduStudent> getAllStudents(String classId) {
        QueryWrapper<EduStudent> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id", classId);
        List<EduStudent> list = eduStudentService.list(wrapper);

        return list;
    }

    //查询指定日期指定第几节课所有未签到的学生
    @Override
    public List<EduNoSignStudentInfo> getAllNoSign(SignGetAllNOSignStudent signGetAllNOSignStudent) {
        String classId = signGetAllNOSignStudent.getClassId();
        String date = signGetAllNOSignStudent.getDate();
        //第几节课
        String keNumber = signGetAllNOSignStudent.getKeNumber();

        if (StringUtils.isEmpty(classId)){
            throw new LLException(20001, "classId为空");
        }

        if(StringUtils.isEmpty(date)){
            throw new LLException(20001, "date为空");
        }

        if (StringUtils.isEmpty(keNumber)){
            throw new LLException(20001, "keNumber为空");
        }

        //以班级为单位,根据班级id查询所有未签到(is_sign=0)的信息
        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id", classId);
        wrapper.eq("is_sign", "0");
        wrapper.eq("ke_number", keNumber);
        wrapper.eq("sign_date", date);
        //返回结果,只需要studentId
        wrapper.select("student_id");
        List<EduSign> eduSignList = baseMapper.selectList(wrapper);

        //判断集合长度是否为0
        if (eduSignList.size() == 0){
            throw new LLException(20001, "查询参数错误或者记录为空");
        }

        //封装所有未签到的学生id
        List<String> studentIdList = new ArrayList<>();
        for (EduSign eduSign : eduSignList) {
            String studentId = eduSign.getStudentId();
            studentIdList.add(studentId);
        }
        System.out.println("指定日期指定第几节课所有未签到的学生Id: " + studentIdList);

        Collection<EduStudent> eduStudents = eduStudentService.listByIds(studentIdList);
        //因为学生对象包含了敏感信息(密码字段,虽然密码经过md5加密,但要以防万一)
        //创建新的实体类EduNoSignStudentInfo,封装学生信息,去除敏感信息
        List<EduNoSignStudentInfo> eduNoSignStudentInfoList = new ArrayList<>();
        for (EduStudent student : eduStudents) {
            EduNoSignStudentInfo noSignStudentInfo = new EduNoSignStudentInfo();
//            noSignStudentInfo.setId(student.getId());
//            noSignStudentInfo.setClassId(student.getClassId());
//            noSignStudentInfo.setAvatar(student.getAvatar());
            //不用一个一个set,使用工具类,和上面那个遍历设值的效果一样
            BeanUtils.copyProperties(student, noSignStudentInfo);
            eduNoSignStudentInfoList.add(noSignStudentInfo);
        }

        return eduNoSignStudentInfoList;
    }

    //查询指定日期指定第几节课所有已签到的学生
    @Override
    public List<EduSignStudentInfo> getAllSign(SignGetAllNOSignStudent signGetAllNOSignStudent) {
        String classId = signGetAllNOSignStudent.getClassId();
        String date = signGetAllNOSignStudent.getDate();
        //第几节课
        String keNumber = signGetAllNOSignStudent.getKeNumber();

        if (StringUtils.isEmpty(classId)){
            throw new LLException(20001, "classId为空");
        }

        if(StringUtils.isEmpty(date)){
            throw new LLException(20001, "date为空");
        }

        if (StringUtils.isEmpty(keNumber)){
            throw new LLException(20001, "keNumber为空");
        }

        //以班级为单位,根据班级id查询已经签到学生(is_sign=1)的信息
        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id", classId);
        wrapper.eq("is_sign", "1");
        wrapper.eq("ke_number", keNumber);
        wrapper.eq("sign_date", date);
        //返回结果,需要studentId,还有签到时间
        wrapper.select("student_id","sign_time");
        List<EduSign> eduSignList = baseMapper.selectList(wrapper);

        //如果签到表没有已经签到的学生,直接返回相应信息,不用往下查询学生的信息信息
        if (eduSignList.size() == 0){
            throw new LLException(20001, "查询参数错误或者记录为空");
        }

        //封装所有已经签到过的学生id,用于查询学生的详细信息
        List<String> studentIdList = new ArrayList<>();
        for (EduSign eduSign : eduSignList) {
            String studentId = eduSign.getStudentId();
            studentIdList.add(studentId);
        }
        System.out.println("所有已经签到的学生id: " + studentIdList);

        //封装所有已经签到过的学生id和签到时间,key:学生Id, value:签到时间
        Map<String, LocalTime> idAndSignTime = new HashMap<>();
        for (EduSign eduSign : eduSignList) {
            String studentId = eduSign.getStudentId();
            LocalTime signTime = eduSign.getSignTime();
            idAndSignTime.put(studentId, signTime);
        }

        Collection<EduStudent> eduStudents = eduStudentService.listByIds(studentIdList);
        //因为学生对象包含了敏感信息(密码字段,虽然密码经过md5加密,但要以防万一)
        //创建新的实体类EduSignStudentInfo,封装学生信息,去除敏感信息
        List<EduSignStudentInfo> eduSignStudentInfoList = new ArrayList<>();
        for (EduStudent student : eduStudents) {
            EduSignStudentInfo eduSignStudentInfo = new EduSignStudentInfo();
//            noSignStudentInfo.setId(student.getId());
//            noSignStudentInfo.setClassId(student.getClassId());
//            noSignStudentInfo.setAvatar(student.getAvatar());
            //不用一个一个set,使用工具类,和上面那个遍历设值的效果一样
            BeanUtils.copyProperties(student, eduSignStudentInfo);

            //添加签到时间
            eduSignStudentInfo.setSignTime(idAndSignTime.get(eduSignStudentInfo.getId()));

            eduSignStudentInfoList.add(eduSignStudentInfo);
        }

        return eduSignStudentInfoList;
    }

    //查询今天第几节课所有已签到的学生
    @Override
    public List<EduSignStudentInfo> getAllSignByToday(SignGetSignStudentByTodayVo signGetSignStudentByTodayVo) {
        String classId = signGetSignStudentByTodayVo.getClassId();
        String keNumber = signGetSignStudentByTodayVo.getKeNumber();
        String date = LocalDate.now().toString();

        if (StringUtils.isEmpty(classId)){
            throw new LLException(20001, "classId为空");
        }

        if(StringUtils.isEmpty(date)){
            throw new LLException(20001, "date为空");
        }

        if (StringUtils.isEmpty(keNumber)){
            throw new LLException(20001, "keNumber为空");
        }

        //以班级为单位,根据班级id查询已经签到学生(is_sign=1)的信息
        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id", classId);
        wrapper.eq("is_sign", "1");
        wrapper.eq("ke_number", keNumber);
        wrapper.eq("sign_date", date);
        //返回结果,需要studentId,还有签到时间
        wrapper.select("student_id","sign_time");
        List<EduSign> eduSignList = baseMapper.selectList(wrapper);

        //如果签到表没有已经签到的学生,直接返回相应信息,不用往下查询学生的信息信息
        if (eduSignList.size() == 0){
            throw new LLException(20001, "查询参数错误或者记录为空");
        }

        //封装所有已经签到过的学生id,用于查询学生的详细信息
        List<String> studentIdList = new ArrayList<>();
        for (EduSign eduSign : eduSignList) {
            String studentId = eduSign.getStudentId();
            studentIdList.add(studentId);
        }
        System.out.println("所有已经签到的学生id: " + studentIdList);

        //封装所有已经签到过的学生id和签到时间,key:学生Id, value:签到时间
        Map<String, LocalTime> idAndSignTime = new HashMap<>();
        for (EduSign eduSign : eduSignList) {
            String studentId = eduSign.getStudentId();
            LocalTime signTime = eduSign.getSignTime();
            idAndSignTime.put(studentId, signTime);
        }

        Collection<EduStudent> eduStudents = eduStudentService.listByIds(studentIdList);
        //因为学生对象包含了敏感信息(密码字段,虽然密码经过md5加密,但要以防万一)
        //创建新的实体类EduSignStudentInfo,封装学生信息,去除敏感信息
        List<EduSignStudentInfo> eduSignStudentInfoList = new ArrayList<>();
        for (EduStudent student : eduStudents) {
            EduSignStudentInfo eduSignStudentInfo = new EduSignStudentInfo();
//            noSignStudentInfo.setId(student.getId());
//            noSignStudentInfo.setClassId(student.getClassId());
//            noSignStudentInfo.setAvatar(student.getAvatar());
            //不用一个一个set,使用工具类,和上面那个遍历设值的效果一样
            BeanUtils.copyProperties(student, eduSignStudentInfo);

            //添加签到时间
            eduSignStudentInfo.setSignTime(idAndSignTime.get(eduSignStudentInfo.getId()));

            eduSignStudentInfoList.add(eduSignStudentInfo);
        }

        return eduSignStudentInfoList;
    }

    //查询今天第几节课所有未签到的学生
    @Override
    public List<EduNoSignStudentInfo> getAllNoSignByToday(SignGetSignStudentByTodayVo signGetSignStudentByTodayVo) {
        String classId = signGetSignStudentByTodayVo.getClassId();
        String keNumber = signGetSignStudentByTodayVo.getKeNumber();
        String date = LocalDate.now().toString();

        if (StringUtils.isEmpty(classId)){
            throw new LLException(20001, "classId为空");
        }

        if(StringUtils.isEmpty(date)){
            throw new LLException(20001, "date为空");
        }

        if (StringUtils.isEmpty(keNumber)){
            throw new LLException(20001, "查询参数错误或者记录为空");
        }

        //以班级为单位,根据班级id查询所有未签到(is_sign=0)的信息
        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id", classId);
        wrapper.eq("is_sign", "0");
        wrapper.eq("ke_number", keNumber);
        wrapper.eq("sign_date", date);
        //返回结果,只需要studentId
        wrapper.select("student_id");
        List<EduSign> eduSignList = baseMapper.selectList(wrapper);

        //判断集合长度是否为0
        if (eduSignList.size() == 0){
            throw new LLException(20001, "记录为空");
        }

        //封装所有未签到的学生id
        List<String> studentIdList = new ArrayList<>();
        for (EduSign eduSign : eduSignList) {
            String studentId = eduSign.getStudentId();
            studentIdList.add(studentId);
        }
        System.out.println("指定日期指定第几节课所有未签到的学生Id: " + studentIdList);

        Collection<EduStudent> eduStudents = eduStudentService.listByIds(studentIdList);
        //因为学生对象包含了敏感信息(密码字段,虽然密码经过md5加密,但要以防万一)
        //创建新的实体类EduNoSignStudentInfo,封装学生信息,去除敏感信息
        List<EduNoSignStudentInfo> eduNoSignStudentInfoList = new ArrayList<>();
        for (EduStudent student : eduStudents) {
            EduNoSignStudentInfo noSignStudentInfo = new EduNoSignStudentInfo();
//            noSignStudentInfo.setId(student.getId());
//            noSignStudentInfo.setClassId(student.getClassId());
//            noSignStudentInfo.setAvatar(student.getAvatar());
            //不用一个一个set,使用工具类,和上面那个遍历设值的效果一样
            BeanUtils.copyProperties(student, noSignStudentInfo);
            eduNoSignStudentInfoList.add(noSignStudentInfo);
        }

        return eduNoSignStudentInfoList;
    }

    //修改某位学生的考勤信息(指定日期指定第几节课)
    @Override
    public boolean UpdateOneStudentSignInfo(SignUpdateOneStudentSignInfo signUpdateOneStudentSignInfo) {
        String classId = signUpdateOneStudentSignInfo.getClassId();
        String studentId = signUpdateOneStudentSignInfo.getStudentId();
        String date = signUpdateOneStudentSignInfo.getDate();
        String keNumber = signUpdateOneStudentSignInfo.getKeNumber();
        String isSign = signUpdateOneStudentSignInfo.getIsSign();

        if (StringUtils.isEmpty(classId)){
            throw new LLException(20001, "classId为空");
        }

        if (StringUtils.isEmpty(studentId)){
            throw new LLException(20001, "studentId为空");
        }

        if (StringUtils.isEmpty(date)){
            throw new LLException(20001, "date为空");
        }

        if(StringUtils.isEmpty(keNumber)){
            throw new LLException(20001, "KeNumber为空");
        }

        if(StringUtils.isEmpty(isSign)){
            throw new LLException(20001, "isSign为空");
        }

        //查询要进行修改签到信息的学生
        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id", classId);
        wrapper.eq("student_id", studentId);
        wrapper.eq("sign_date", date);
        wrapper.eq("ke_number", keNumber);
        EduSign eduSign = new EduSign();
        eduSign.setIsSign(isSign);

        int update = baseMapper.update(eduSign, wrapper);

        if (update > 0 ){
            return true;
        } else {
            return false;
        }
    }

    //查询某位学生的考勤信息(指定日期指定第几节课)
    @Override
    public SignOneStudentSignInfoVo GetOneStudentSignInfo(SignGetOneStudentSignInfoVo signGetOneStudentSignInfoVo) {
        String studentId = signGetOneStudentSignInfoVo.getStudentId();
        String date = signGetOneStudentSignInfoVo.getDate();
        String keNumber = signGetOneStudentSignInfoVo.getKeNumber();

        if (StringUtils.isEmpty(studentId)){
            throw new LLException(20001, "studentId为空");
        }

        if (StringUtils.isEmpty(date)){
            throw new LLException(20001, "date为空");
        }

        if(StringUtils.isEmpty(keNumber)){
            throw new LLException(20001, "KeNumber为空");
        }

        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("student_id", studentId);
        wrapper.eq("sign_date", date);
        wrapper.eq("ke_number", keNumber);

        EduSign eduSign = baseMapper.selectOne(wrapper);

        if (StringUtils.isEmpty(eduSign)){
            throw new LLException(20001, "记录为空或者参数错误");
        }

        EduStudent eduStudent = eduStudentService.getById(eduSign.getStudentId());
        if (StringUtils.isEmpty(eduStudent)){
            throw new LLException(20001, "查询学生基本信息出错");
        }
        SignOneStudentSignInfoVo signOneStudentSignInfoVo = new SignOneStudentSignInfoVo();
        BeanUtils.copyProperties(eduStudent, signOneStudentSignInfoVo);
        signOneStudentSignInfoVo.setIsSign(eduSign.getIsSign());
        signOneStudentSignInfoVo.setSignTime(eduSign.getSignTime());

        return signOneStudentSignInfoVo;
    }
    
    //查询某位学生一天的考勤信息(指定日期指定学生Id)
    @Override
    public SignStudentSignInfoByOneDayVo getStudentSignInfoByOneDay(SignGetStudentSignInfoByOneDayVo signGetStudentSignInfoByOneDayVo) {
        String studentId = signGetStudentSignInfoByOneDayVo.getStudentId();
        String date = signGetStudentSignInfoByOneDayVo.getDate();

        if (StringUtils.isEmpty(studentId)){
            throw new LLException(20001, "studentId为空");
        }

        if (StringUtils.isEmpty(date)){
            throw new LLException(20001, "date为空");
        }

        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("student_id", studentId);
        wrapper.eq("sign_date", date);

        List<EduSign> signList = baseMapper.selectList(wrapper);

        Map<String, List<String>> statusAndKe = new HashMap<>();

        statusAndKe.put("truantKe", new ArrayList<>()); //旷课信息的封装
        statusAndKe.put("successKe", new ArrayList<>()); //出勤信息的封装
        statusAndKe.put("lateKe", new ArrayList<>());    //迟到信息的封装
        statusAndKe.put("leaveKe", new ArrayList<>());   //请假信息的封装

        int truantCount = 0;  //旷课次数
        int successCount = 0; //出勤次数
        int lateCount = 0;    //迟到次数
        int leaveCount = 0;   //请假次数

        for (EduSign eduSign : signList) {
            String keNumber = eduSign.getKeNumber();
            //判断是第几节课
            if ("one".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            } else if ("two".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            }  else if ("three".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            } else if ("four".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            } else if ("five".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            }else if ("six".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            }else if ("seven".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            }else if ("eight".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            }else if ("night".equals(keNumber)){
                //判断考勤状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("truantKe").add(eduKeInfoName);
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("successKe").add(eduKeInfoName);
                } else if ("2".equals(isSign)){
                    lateCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("lateKe").add(eduKeInfoName);
                } else if ("3".equals(isSign)){
                    leaveCount += 1;
                    //封装这节课的课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(eduSign.getKeInfoId());
                    //获取课程名称
                    String eduKeInfoName = eduKeInfo.getName();
                    statusAndKe.get("leaveKe").add(eduKeInfoName);
                }
            }
        }

        //获取学生信息
        EduStudent eduStudent = eduStudentService.getById(studentId);
        SignStudentSignInfoByOneDayVo signStudentSignInfoByOneDayVo = new SignStudentSignInfoByOneDayVo();
        signStudentSignInfoByOneDayVo.setLateCount(lateCount);
        signStudentSignInfoByOneDayVo.setLeaveCount(leaveCount);
        signStudentSignInfoByOneDayVo.setSuccessCount(successCount);
        signStudentSignInfoByOneDayVo.setTruantCount(truantCount);
        signStudentSignInfoByOneDayVo.setStatusAndKe(statusAndKe);
        signStudentSignInfoByOneDayVo.setName(eduStudent.getName());
        signStudentSignInfoByOneDayVo.setEduId(eduStudent.getEduId());
        signStudentSignInfoByOneDayVo.setNickname(eduStudent.getNickname());
        signStudentSignInfoByOneDayVo.setClassId(eduStudent.getClassId());
        signStudentSignInfoByOneDayVo.setAvatar(eduStudent.getAvatar());

        return signStudentSignInfoByOneDayVo;
    }

    //查询某班某一天的考勤信息(指定班级Id指定日期)
    @Override
    public SignClassInfoByOneDayVo GetClassSignInfoByOneDay(SignGetClassSignInfoByOneDayVo signGetClassSignInfoByOneDayVo) {
        String classId = signGetClassSignInfoByOneDayVo.getClassId();
        String date = signGetClassSignInfoByOneDayVo.getDate();

        if (StringUtils.isEmpty(classId)){
            throw new LLException(20001, "classId为空");
        }

        if (StringUtils.isEmpty(date)){
            throw new LLException(20001, "date为空");
        }

        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id",classId);
        wrapper.eq("sign_date", date);

        //查询所有复合条件的签到记录
        List<EduSign> signList = baseMapper.selectList(wrapper);

        SignClassInfoByOneDayVo signClassInfoByOneDayVo = new SignClassInfoByOneDayVo();

        // Map<String, List<String>> statusAndKe = new HashMap<>();
        // key:旷课(出勤,迟到,请假) value: map => key:学生id value:旷课(出勤,迟到,请假)的课程名的集合
        Map<String, Map<String, List<String>>> statusAndKe = new HashMap<>();


        statusAndKe.put("truantKe", new HashMap<>());  //旷课信息的封装
        statusAndKe.put("successKe", new HashMap<>()); //出勤信息的封装
        statusAndKe.put("lateKe", new HashMap<>());    //迟到信息的封装
        statusAndKe.put("leaveKe", new HashMap<>());   //请假信息的封装

        int truantCount = 0;  //旷课次数
        int successCount = 0; //出勤次数
        int lateCount = 0;    //迟到次数
        int leaveCount = 0;   //请假次数

        for (EduSign eduSign : signList) {
            //判断是第几节课
            String keNumber = eduSign.getKeNumber();
            if ("one".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            } else if ("two".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            } else if ("three".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            } else if ("four".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            } else if ("five".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            } else if ("six".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            } else if ("seven".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            } else if ("eight".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            } else if ("night".equals(keNumber)){
                //判断签到状态(0或null未签到(旷课), 1已签到(出勤), 2迟到, 3请假)
                String isSign = eduSign.getIsSign();
                if ("0".equals(isSign)){
                    //旷课次数 +1
                    truantCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("truantKe").get(studentId))){
                        statusAndKe.get("truantKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("truantKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("1".equals(isSign)){
                    //出勤次数 + 1
                    successCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("successKe").get(studentId))){
                        statusAndKe.get("successKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("successKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("2".equals(isSign)){
                    //迟到次数 + 1
                    lateCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("lateKe").get(studentId))){
                        statusAndKe.get("lateKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("lateKe").get(studentId).add(eduKeInfoName);
                    }
                } else if ("3".equals(isSign)){
                    //请假次数 + 1
                    leaveCount += 1;

                    String studentId = eduSign.getStudentId();    //学生id
                    String keInfoId = eduSign.getKeInfoId();      //课程详细信息id
                    EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId); //根据课程详细信息id查询课程的详细信息
                    String eduKeInfoName = eduKeInfo.getName(); //课程名

                    List<String> eduKeInfoNames = new ArrayList<>(); //创建集合封装课程名,因为可能旷课(出勤,迟到,请假)多节
                    eduKeInfoNames.add(eduKeInfoName);

                    if (StringUtils.isEmpty(statusAndKe.get("leaveKe").get(studentId))){
                        statusAndKe.get("leaveKe").put(studentId, eduKeInfoNames);
                    } else {
                        statusAndKe.get("leaveKe").get(studentId).add(eduKeInfoName);
                    }
                }
            }

        }

        signClassInfoByOneDayVo.setTruantCount(truantCount);
        signClassInfoByOneDayVo.setSuccessCount(successCount);
        signClassInfoByOneDayVo.setLateCount(lateCount);
        signClassInfoByOneDayVo.setLeaveCount(leaveCount);
        signClassInfoByOneDayVo.setStatusAndKe(statusAndKe);

        return signClassInfoByOneDayVo;
    }

    //给某个学生某节课评分
    @Override
    public boolean addKeSocreWithStudent(KeScoreVO keScoreVO) {
        String studentId = keScoreVO.getStudentId();
        String keNumber = keScoreVO.getKeNumber();
        String score = keScoreVO.getScore();
        String text = keScoreVO.getText();
        String signDate = keScoreVO.getSignDate();

        //待续 判断是否为空

        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("student_id",studentId);
        wrapper.eq("ke_number",keNumber);
        wrapper.eq("sign_date", signDate);

        EduSign eduSign = baseMapper.selectOne(wrapper);

        eduSign.setKeScore(score);
        eduSign.setKeScoreText(text);

        int flag = baseMapper.updateById(eduSign);
        return flag > 0 ? true : false;
    }


    // 查询某学生一周的的考勤信息(指定学生Id指定第几周)
    @Override
    public SignStudentSignInfoByOneWeekVo GetStudentSignInfoByWeek(SignStudentSignInfoByWeekVo signStudentSignInfoByWeekVo) {
        String studentId = signStudentSignInfoByWeekVo.getStudentId(); //学生id
        String week = signStudentSignInfoByWeekVo.getWeek(); //第几周

        if (StringUtils.isEmpty(studentId)){
            throw new LLException(20001, "学生id为空");
        }

        if (StringUtils.isEmpty(week)){
            throw new LLException(20001, "周数为空");
        }

        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("week", week);
        wrapper.eq("student_id", studentId);

        List<EduSign> signList = baseMapper.selectList(wrapper);

        SignStudentSignInfoByOneWeekVo signStudentSignInfoByOneWeekVo = new SignStudentSignInfoByOneWeekVo();

        int truantCount = 0;  //旷课次数
        int successCount = 0; //出勤次数
        int lateCount = 0;    //迟到次数
        int leaveCount = 0;   //请假次数

        for (EduSign eduSign : signList) {
            String isSign = eduSign.getIsSign();
            if ("0".equals(isSign)){
                //旷课次数 +1
                truantCount += 1;
            } else if ("1".equals(isSign)){
                //出勤次数 + 1
                successCount += 1;
            } else if ("2".equals(isSign)){
                //迟到次数 + 1
                lateCount += 1;
            } else if ("3".equals(isSign)){
                //请假次数 + 1
                leaveCount += 1;
            }
        }

        //根据学生id查询学生详细信息
        EduStudent eduStudent = eduStudentService.getById(studentId);
        BeanUtils.copyProperties(eduStudent, signStudentSignInfoByOneWeekVo);
        signStudentSignInfoByOneWeekVo.setTruantCount(truantCount);
        signStudentSignInfoByOneWeekVo.setSuccessCount(successCount);
        signStudentSignInfoByOneWeekVo.setLateCount(lateCount);
        signStudentSignInfoByOneWeekVo.setLeaveCount(leaveCount);

        return signStudentSignInfoByOneWeekVo;
    }

    //查询某班一周的的考勤信息(指定班级Id指定第几周)
    @Override
    public SignClassSignInfoByOneWeekVo getClassSignInfoByWeek(SignClassSignInfoByWeekVo signClassSignInfoByWeekVo) {
        String classId = signClassSignInfoByWeekVo.getClassId();
        String week = signClassSignInfoByWeekVo.getWeek();

        if (StringUtils.isEmpty(classId)){
            throw new LLException(20001, "班级id为空");
        }

        if (StringUtils.isEmpty(week)){
            throw new LLException(20001, "周数为空");
        }

        QueryWrapper<EduSign> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id", classId);
        wrapper.eq("week", week);

        List<EduSign> signList = baseMapper.selectList(wrapper);

        SignClassSignInfoByOneWeekVo signClassSignInfoByOneWeekVo = new SignClassSignInfoByOneWeekVo();

        Map<String, List<String>> statusAndKe = new HashMap<>();

        statusAndKe.put("truantKe", new ArrayList<>()); //旷课信息的封装
        statusAndKe.put("successKe", new ArrayList<>()); //出勤信息的封装
        statusAndKe.put("lateKe", new ArrayList<>());    //迟到信息的封装
        statusAndKe.put("leaveKe", new ArrayList<>());   //请假信息的封装

        int truantCount = 0;  //旷课次数
        int successCount = 0; //出勤次数
        int lateCount = 0;    //迟到次数
        int leaveCount = 0;   //请假次数

        for (EduSign eduSign : signList) {
            String isSign = eduSign.getIsSign();
            if ("0".equals(isSign)){
                //旷课次数 +1
                truantCount += 1;
                //获取旷课学生的姓名
                String studentId = eduSign.getStudentId();
                String studentName = eduStudentService.getById(studentId).getName();
                statusAndKe.get("truantKe").add(studentName);
            } else if ("1".equals(isSign)){
                //出勤次数 + 1
                successCount += 1;
                //获取旷课学生的姓名
                String studentId = eduSign.getStudentId();
                String studentName = eduStudentService.getById(studentId).getName();
                statusAndKe.get("successKe").add(studentName);
            } else if ("2".equals(isSign)){
                lateCount += 1;
                //获取迟到学生的姓名
                String studentId = eduSign.getStudentId();
                String studentName = eduStudentService.getById(studentId).getName();
                statusAndKe.get("lateKe").add(studentName);
            } else if ("3".equals(isSign)){
                leaveCount += 1;
                //获取请假学生的姓名
                String studentId = eduSign.getStudentId();
                String studentName = eduStudentService.getById(studentId).getName();
                statusAndKe.get("leaveKe").add(studentName);
            }
        }

        signClassSignInfoByOneWeekVo.setTruantCount(truantCount);
        signClassSignInfoByOneWeekVo.setSuccessCount(successCount);
        signClassSignInfoByOneWeekVo.setLateCount(lateCount);
        signClassSignInfoByOneWeekVo.setLeaveCount(leaveCount);
        signClassSignInfoByOneWeekVo.setStatusAndKe(statusAndKe);

        return signClassSignInfoByOneWeekVo;
    }


    @Test
    public void test() {
        Map<String, Map<String,List>> ProfessionSignByDayVO = new HashMap<>();
        ProfessionSignByDayVO.put("刘龙", new HashMap<>());
        System.out.println(StringUtils.isEmpty(ProfessionSignByDayVO.get("刘龙")));

        List<String> list = new ArrayList<>();
        list.add("刘");
        System.out.println(list.contains("刘龙"));

    }

    //查询某专业下所有班级某天的的考勤信息
    @Override
    public SignProfessionSignInfoByDayVo GetProfessionSignByDay(SignProfessioByDayVo signProfessioByDayVo) {
        String professiId = signProfessioByDayVo.getProfessiId(); //专业id
        String date = signProfessioByDayVo.getDate(); //日期

        if (StringUtils.isEmpty(professiId)){
            throw new LLException(20001, "专业id为空");
        }

        if (StringUtils.isEmpty(date)){
            throw new LLException(20001, "日期为空");
        }

        // 查询指定专业的所有班级
        QueryWrapper<EduClass> wrapper = new QueryWrapper<>();
        wrapper.eq("profession_id",professiId);
        List<EduClass> eduClassList = eduClassService.list(wrapper);

        // Key: 班级名 Value: 不同签到状态的学生姓名
        Map<String, Map<String,List<String>>> professionSignByDayVO = new HashMap<>();
        // Key: 班级名 Value: 不同签到状态的学生人数
        Map<String, Map<String, Integer>> professionSignCount = new HashMap<>();

        //遍历每个班
        for (EduClass eduClass : eduClassList) {
            String className = eduClass.getClassName(); //班级名
            String classId = eduClass.getId(); //班级id

            //根据班级id和日期查询所有签到记录
            QueryWrapper<EduSign> eduSignQueryWrapper = new QueryWrapper<>();
            eduSignQueryWrapper.eq("class_id", classId);
            eduSignQueryWrapper.eq("sign_date", date);
            List<EduSign> signList = baseMapper.selectList(eduSignQueryWrapper);

            //添加信息,key:班级名
            professionSignByDayVO.put(className, new HashMap<>());
            professionSignCount.put(className, new HashMap<>());

            int truantCount = 0;  //旷课次数
            int successCount = 0; //出勤次数
            int lateCount = 0;    //迟到次数
            int leaveCount = 0;   //请假次数

            // 遍历所有签到记录
            for (EduSign eduSign : signList) {
                String isSign = eduSign.getIsSign(); //获取签到状态
                if ("0".equals(isSign)){ //旷课
                    //获取旷课学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("truantKe"))){
                        professionSignByDayVO.get(className).put("truantKe", new ArrayList());
                        //旷课次数 +1
                        truantCount += 1;
                        professionSignByDayVO.get(className).get("truantKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("truantKe").contains(studentName)){
                            //旷课次数 +1
                            truantCount += 1;
                            professionSignByDayVO.get(className).get("truantKe").add(studentName);
                        }
                    }
                } else if ("1".equals(isSign)){
                    //获取出勤学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("successKe"))){
                        professionSignByDayVO.get(className).put("successKe", new ArrayList());
                        //出勤次数 + 1
                        successCount += 1;
                        professionSignByDayVO.get(className).get("successKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("successKe").contains(studentName)){
                            //出勤次数 + 1
                            successCount += 1;
                            professionSignByDayVO.get(className).get("successKe").add(studentName);
                        }
                    }
                } else if ("2".equals(isSign)){
                    //获取迟到学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("lateKe"))){
                        professionSignByDayVO.get(className).put("lateKe", new ArrayList());
                        //迟到次数 + 1
                        lateCount += 1;
                        professionSignByDayVO.get(className).get("lateKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("lateKe").contains(studentName)){
                            //迟到次数 + 1
                            lateCount += 1;
                            professionSignByDayVO.get(className).get("lateKe").add(studentName);
                        }
                    }
                } else if ("3".equals(isSign)){
                    //获取请假学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("leaveKe"))){
                        professionSignByDayVO.get(className).put("leaveKe", new ArrayList());
                        //请假次数 + 1
                        leaveCount += 1;
                        professionSignByDayVO.get(className).get("leaveKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("leaveKe").contains(studentName)){
                            //请假次数 + 1
                            leaveCount += 1;
                            professionSignByDayVO.get(className).get("leaveKe").add(studentName);
                        }
                    }
                }
            }

            professionSignCount.get(className).put("truantCount", truantCount);
            professionSignCount.get(className).put("successCount", successCount);
            professionSignCount.get(className).put("lateCount", lateCount);
            professionSignCount.get(className).put("leaveCount", leaveCount);
        }

        SignProfessionSignInfoByDayVo signProfessionSignInfoByDayVo = new SignProfessionSignInfoByDayVo();
        signProfessionSignInfoByDayVo.setProfessionSignByDayVO(professionSignByDayVO);
        signProfessionSignInfoByDayVo.setProfessionSignCount(professionSignCount);
        return signProfessionSignInfoByDayVo;
    }

    //查询某年级某专业某天的考勤信息(指定年级Id指定专业Id指定要查询的日期)
    @Override
    public SignProfessionSignInfoByDayVo getEqualGradeDisaffinityProfessionSignByDay(SignFindGradeAndProfessionByDayVo signFindGradeAndProfessionByDayVo) {
        String gradeId = signFindGradeAndProfessionByDayVo.getGradeId();
        String professiId = signFindGradeAndProfessionByDayVo.getProfessiId();
        String date = signFindGradeAndProfessionByDayVo.getDate();

        if (StringUtils.isEmpty(gradeId)){
            throw new LLException(20001, "年级Id为空");
        }

        if (StringUtils.isEmpty(professiId)){
            throw new LLException(20001, "专业Id为空");
        }

        if (StringUtils.isEmpty(date)){
            throw new LLException(20001, "日期为空");
        }

        QueryWrapper<EduClass> wrapper = new QueryWrapper<>();
        wrapper.eq("grade_id", gradeId);
        wrapper.eq("profession_id", professiId);

        List<EduClass> eduClassList = eduClassService.list(wrapper);

        // Key: 班级名 Value: 不同签到状态的学生姓名
        Map<String, Map<String,List<String>>> professionSignByDayVO = new HashMap<>();
        // Key: 班级名 Value: 不同签到状态的学生人数
        Map<String, Map<String, Integer>> professionSignCount = new HashMap<>();

        for (EduClass eduClass : eduClassList) {
            String className = eduClass.getClassName(); //班级名
            String classId = eduClass.getId(); //班级id

            QueryWrapper<EduSign> signWrapper = new QueryWrapper<>();
            signWrapper.eq("class_id", classId);
            signWrapper.eq("sign_date", date);
            List<EduSign> signList = baseMapper.selectList(signWrapper);

            //添加信息,key:班级名
            professionSignByDayVO.put(className, new HashMap<>());
            professionSignCount.put(className, new HashMap<>());

            int truantCount = 0;  //旷课次数
            int successCount = 0; //出勤次数
            int lateCount = 0;    //迟到次数
            int leaveCount = 0;   //请假次数

            // 遍历所有签到记录
            for (EduSign eduSign : signList) {
                String isSign = eduSign.getIsSign(); //获取签到状态
                if ("0".equals(isSign)){ //旷课
                    //获取旷课学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("truantKe"))){
                        professionSignByDayVO.get(className).put("truantKe", new ArrayList());
                        //旷课次数 +1
                        truantCount += 1;
                        professionSignByDayVO.get(className).get("truantKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("truantKe").contains(studentName)){
                            //旷课次数 +1
                            truantCount += 1;
                            professionSignByDayVO.get(className).get("truantKe").add(studentName);
                        }
                    }
                } else if ("1".equals(isSign)){
                    //获取出勤学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("successKe"))){
                        professionSignByDayVO.get(className).put("successKe", new ArrayList());
                        //出勤次数 + 1
                        successCount += 1;
                        professionSignByDayVO.get(className).get("successKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("successKe").contains(studentName)){
                            //出勤次数 + 1
                            successCount += 1;
                            professionSignByDayVO.get(className).get("successKe").add(studentName);
                        }
                    }
                } else if ("2".equals(isSign)){
                    //获取迟到学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("lateKe"))){
                        professionSignByDayVO.get(className).put("lateKe", new ArrayList());
                        //迟到次数 + 1
                        lateCount += 1;
                        professionSignByDayVO.get(className).get("lateKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("lateKe").contains(studentName)){
                            //迟到次数 + 1
                            lateCount += 1;
                            professionSignByDayVO.get(className).get("lateKe").add(studentName);
                        }
                    }
                } else if ("3".equals(isSign)){
                    //获取请假学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("leaveKe"))){
                        professionSignByDayVO.get(className).put("leaveKe", new ArrayList());
                        //请假次数 + 1
                        leaveCount += 1;
                        professionSignByDayVO.get(className).get("leaveKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("leaveKe").contains(studentName)){
                            //请假次数 + 1
                            leaveCount += 1;
                            professionSignByDayVO.get(className).get("leaveKe").add(studentName);
                        }
                    }
                }
            }

            professionSignCount.get(className).put("truantCount", truantCount);
            professionSignCount.get(className).put("successCount", successCount);
            professionSignCount.get(className).put("lateCount", lateCount);
            professionSignCount.get(className).put("leaveCount", leaveCount);
        }

        SignProfessionSignInfoByDayVo signProfessionSignInfoByDayVo = new SignProfessionSignInfoByDayVo();
        signProfessionSignInfoByDayVo.setProfessionSignByDayVO(professionSignByDayVO);
        signProfessionSignInfoByDayVo.setProfessionSignCount(professionSignCount);
        return signProfessionSignInfoByDayVo;
    }

    //查询某年级某专业某周的考勤信息(指定年级Id指定专业Id指定要查询的日期)
    @Override
    public SignProfessionSignInfoByDayVo getGradeProfessionSignByWeek(SignFindGradeAndProfessionByWeekVo signFindGradeAndProfessionByWeekVo) {
        String gradeId = signFindGradeAndProfessionByWeekVo.getGradeId();
        String professiId = signFindGradeAndProfessionByWeekVo.getProfessiId();
        String week = signFindGradeAndProfessionByWeekVo.getWeek();

        if (StringUtils.isEmpty(gradeId)){
            throw new LLException(20001, "年级Id为空");
        }

        if (StringUtils.isEmpty(professiId)){
            throw new LLException(20001, "专业Id为空");
        }

        if (StringUtils.isEmpty(week)){
            throw new LLException(20001, "周数为空");
        }

        QueryWrapper<EduClass> wrapper = new QueryWrapper<>();
        wrapper.eq("grade_id", gradeId);
        wrapper.eq("profession_id", professiId);

        List<EduClass> eduClassList = eduClassService.list(wrapper);

        // Key: 班级名 Value: 不同签到状态的学生姓名
        Map<String, Map<String,List<String>>> professionSignByDayVO = new HashMap<>();
        // Key: 班级名 Value: 不同签到状态的学生人数
        Map<String, Map<String, Integer>> professionSignCount = new HashMap<>();

        for (EduClass eduClass : eduClassList) {
            String className = eduClass.getClassName(); //班级名
            String classId = eduClass.getId(); //班级id

            QueryWrapper<EduSign> signWrapper = new QueryWrapper<>();
            signWrapper.eq("class_id", classId);
            signWrapper.eq("week", week);
            List<EduSign> signList = baseMapper.selectList(signWrapper);

            //添加信息,key:班级名
            professionSignByDayVO.put(className, new HashMap<>());
            professionSignCount.put(className, new HashMap<>());

            int truantCount = 0;  //旷课次数
            int successCount = 0; //出勤次数
            int lateCount = 0;    //迟到次数
            int leaveCount = 0;   //请假次数

            // 遍历所有签到记录
            for (EduSign eduSign : signList) {
                String isSign = eduSign.getIsSign(); //获取签到状态
                if ("0".equals(isSign)){ //旷课
                    //获取旷课学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("truantKe"))){
                        professionSignByDayVO.get(className).put("truantKe", new ArrayList());
                        //旷课次数 +1
                        truantCount += 1;
                        professionSignByDayVO.get(className).get("truantKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("truantKe").contains(studentName)){
                            //旷课次数 +1
                            truantCount += 1;
                            professionSignByDayVO.get(className).get("truantKe").add(studentName);
                        }
                    }
                } else if ("1".equals(isSign)){
                    //获取出勤学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("successKe"))){
                        professionSignByDayVO.get(className).put("successKe", new ArrayList());
                        //出勤次数 + 1
                        successCount += 1;
                        professionSignByDayVO.get(className).get("successKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("successKe").contains(studentName)){
                            //出勤次数 + 1
                            successCount += 1;
                            professionSignByDayVO.get(className).get("successKe").add(studentName);
                        }
                    }
                } else if ("2".equals(isSign)){
                    //获取迟到学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("lateKe"))){
                        professionSignByDayVO.get(className).put("lateKe", new ArrayList());
                        //迟到次数 + 1
                        lateCount += 1;
                        professionSignByDayVO.get(className).get("lateKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("lateKe").contains(studentName)){
                            //迟到次数 + 1
                            lateCount += 1;
                            professionSignByDayVO.get(className).get("lateKe").add(studentName);
                        }
                    }
                } else if ("3".equals(isSign)){
                    //获取请假学生的id和姓名
                    String studentId = eduSign.getStudentId();
                    String studentName = eduStudentService.getById(studentId).getName();

                    if (StringUtils.isEmpty(professionSignByDayVO.get(className).get("leaveKe"))){
                        professionSignByDayVO.get(className).put("leaveKe", new ArrayList());
                        //请假次数 + 1
                        leaveCount += 1;
                        professionSignByDayVO.get(className).get("leaveKe").add(studentName);
                    }else {
                        //判断是否有这个名字
                        if (!professionSignByDayVO.get(className).get("leaveKe").contains(studentName)){
                            //请假次数 + 1
                            leaveCount += 1;
                            professionSignByDayVO.get(className).get("leaveKe").add(studentName);
                        }
                    }
                }
            }

            professionSignCount.get(className).put("truantCount", truantCount);
            professionSignCount.get(className).put("successCount", successCount);
            professionSignCount.get(className).put("lateCount", lateCount);
            professionSignCount.get(className).put("leaveCount", leaveCount);
        }

        SignProfessionSignInfoByDayVo signProfessionSignInfoByDayVo = new SignProfessionSignInfoByDayVo();
        signProfessionSignInfoByDayVo.setProfessionSignByDayVO(professionSignByDayVO);
        signProfessionSignInfoByDayVo.setProfessionSignCount(professionSignCount);
        return signProfessionSignInfoByDayVo;
    }

    //获取某个班的学生人数
    @Override
    public int getClassStudentTotal(String classId) {
        QueryWrapper<EduStudent> wrapper = new QueryWrapper<>();
        wrapper.eq("class_id", classId);

        int count = eduStudentService.count(wrapper);
        return count;
    }


    @Test
    public void test3() {

        //获取现在的时间
        LocalDate now = LocalDate.now();

        // 2020-08-31
        LocalDate parse = LocalDate.parse("2020-08-31");
        LocalDate parse2 = LocalDate.parse("2020-09-01");

        int day = (int) (now.toEpochDay() - parse.toEpochDay());
        System.out.println(day);
        System.out.println(day/7);
        System.out.println(day%7);
        System.out.println(8/7);
        System.out.println(parse2.toEpochDay() - parse.toEpochDay());
    }

    //获取现在是第几周
    @Override
    public String getNowWeek() {
        String nowWeek = eduStartWeekService.getNowWeek();
        return nowWeek;
    }

    //获取将要进行签到课程的id(ke_info_id)
    @Override
    public String getKeInfoId(String classId) {
        String keInfoId = eduKeService.findKeInfoId(classId);
        return keInfoId;
    }

    //获取将要签到的课程信息
    @Override
    public EduKeInfo findLaterSignCourseInfo(String classId) {

        String keInfoId = this.getKeInfoId(classId);

        EduKeInfo eduKeInfo = eduKeInfoService.getById(keInfoId);

        return eduKeInfo;
    }

    //获取当前要进行第几节课的签到
    //one two three
    @Override
    public String getNoCourse() {
        String keNumber = eduKeService.findNoAutoSignCourseNumber();
        return keNumber;
    }
}
